<?php echo $this->fetch('header.html'); ?>

<?php echo $this->fetch('title.html'); ?>

<style>
    .coupon_view{background: #fff;}
    .coupon_view h3{text-align: center;margin-top: 10px;}
    .coupon_view .coupon_info{margin:10px;line-height: 24px;padding: 20px;}
    .coupon_view .content{margin: 10px 0;}
    .coupon_view img{width: 100%;}
</style>

<script>
    function add_coupon(coupon_id){
        <?php if (! $this->_var['visitor']['user_id']): ?>
        alert(lang.login_please);
        return;
        <?php endif; ?>
        var url = SITE_URL + '/index.php?app=my_coupon&act=add';
            $.getJSON(url, {'coupon_id': coupon_id}, function (data) {
            if (data.done)
            {
                alert(data.retval);
            }
            else
            {
                alert(data.msg);
            }
        });
    }
</script>
<div class="coupon_view">

    <?php if ($this->_var['coupon']['coupon_bg']): ?>
    <img src="<?php echo $this->_var['site_url']; ?>/<?php echo $this->_var['coupon']['coupon_bg']; ?>" width="100%" />
    <?php endif; ?>
    
    <div class="coupon_info">
        优惠券名称：<?php echo htmlspecialchars($this->_var['coupon']['coupon_name']); ?><br/>
        有效期：：<?php echo local_date("Y-m-d",$this->_var['coupon']['start_time']); ?>至<?php echo local_date("Y-m-d",$this->_var['coupon']['end_time']); ?><br/>
        使用次数：<span style="color:#de2b2c;font-weight:bolder; font-family:verdana;"><?php echo htmlspecialchars($this->_var['coupon']['use_times']); ?></span><br/>
        最低消费：：<span style="color:#de2b2c;font-weight:bolder; font-family:verdana;"><?php echo price_format($this->_var['coupon']['min_amount']); ?></span><br/>
        已领取：：<span style="color:#de2b2c;font-weight:bolder; font-family:verdana;"><?php echo ($this->_var['coupon']['hava_received'] == '') ? '0' : $this->_var['coupon']['hava_received']; ?></span><br/>
        未领取：：<span style="color:#de2b2c;font-weight:bolder; font-family:verdana;"><?php echo ($this->_var['coupon']['not_received'] == '') ? '0' : $this->_var['coupon']['not_received']; ?></span><br/>
        发放店铺：：<a href="<?php echo url('app=store&id=' . $this->_var['store']['store_id']. ''); ?>"><?php echo htmlspecialchars($this->_var['store']['store_name']); ?></a><br/>
        <input onclick="add_coupon(<?php echo $this->_var['coupon']['coupon_id']; ?>)" value="领取" name="Submit" type="button" class=" red_btn" >
        <div class="content">
            <?php echo html_filter($this->_var['coupon']['content']); ?>
        </div>
    </div>

    
    <style>
#mcover {position: fixed;top: 0;left: 0;width: 100%;height: 100%;background: rgba(0, 0, 0, 0.7);display: none;z-index: 20000;}
#mcover img {position: fixed;right: 18px;top: 5px;width: 260px!important;height: 180px!important;z-index: 20001;}
.text {margin: 15px 0;font-size: 14px;word-wrap: break-word;color: #727272;}
#mess_share {margin: 15px 0;display: block;}
#share_1{float: left;width: 49%;display: block;}
#share_2 {float: right;width: 49%;display: block;}
.clr {display: block;clear: both;height: 0;overflow: hidden;}
.button2 {font-size: 16px;padding: 8px 0;border: 1px solid #adadab;color: #000000;background-color: #e8e8e8;background-image: linear-gradient(to top, #dbdbdb, #f4f4f4);box-shadow: 0 1px 1px rgba(0, 0, 0, 0.45), inset 0 1px 1px #efefef;text-shadow: 0.5px 0.5px 1px #fff;text-align: center;border-radius: 3px;width: 100%;}
#mess_share img {width: 22px!important;height: 22px!important;vertical-align: top;border: 0;}
    </style>
    <div class="text" id="content">
        <div id="mess_share">
            <div id="share_1">
                <button class="button2" onclick="document.getElementById('mcover').style.display='block';">
                    <img src="<?php echo $this->res_base . "/" . 'images/icon_msg.png'; ?>" width="64" height="64" />
                    &nbsp;发送给朋友
                </button>
            </div>
            <div id="share_2">
                <button class="button2" onclick="document.getElementById('mcover').style.display='block';">
                    <img src="<?php echo $this->res_base . "/" . 'images/icon_timeline.png'; ?>" width="64" height="64" />
                    &nbsp;分享到朋友圈
                </button>
            </div>
            <div class="clr"></div>
        </div>
    </div>
    <div id="mcover" onclick="document.getElementById('mcover').style.display='';" style="display:none;">
        <img src="<?php echo $this->res_base . "/" . 'images/guide.png'; ?>" />
    </div>
</div>
<script>
$(function(){

                $(".content img").each(function(){
                var img_src=$(this).attr("src");
                $(this).attr("src",img_src.replace("./data","<?php echo $this->_var['site_url']; ?>/data"));
})
})
</script>

<?php echo $this->fetch('footer.html'); ?>